package com.wanmait.recruit.service.impl;

import com.github.pagehelper.PageInfo;
import com.wanmait.recruit.pojo.Person;
import com.wanmait.recruit.service.ResumeService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

import com.wanmait.recruit.mapper.ResumeMapper;
import com.wanmait.recruit.pojo.Resume;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

@Service("resumeService")
@Transactional(rollbackFor = Exception.class)
public class ResumeServiceImpl implements ResumeService {

    @Resource
    private ResumeMapper resumeMapper;

    @Override
    public Resume selectOneByPerson(Person person){
        return resumeMapper.selectOneByPerosnId(person.getId());
    }

    public int deleteByPrimaryKey(Integer id){
        return resumeMapper.deleteByPrimaryKey(id);
    }

    public void insert(Resume record){
        resumeMapper.insert(record);
    }

    @Override
    public void delete(Resume object) {

    }

    @Override
    public void update(Resume object) {

    }

    @Override
    public PageInfo<Resume> search(int pageNum, int pageSize) {
        return null;
    }

    public int insertSelective(Resume record){
        return resumeMapper.insertSelective(record);
    }

    public Resume selectByPrimaryKey(Integer id){
        return resumeMapper.selectByPrimaryKey(id);
    }

    public int updateByPrimaryKeySelective(Resume record){
        return resumeMapper.updateByPrimaryKeySelective(record);
    }

    public int updateByPrimaryKey(Resume record){
        return resumeMapper.updateByPrimaryKey(record);
    }

    @Override
    public Resume findById(Integer id) {
        return resumeMapper.selectByPrimaryKey(id);
    }

    @Override
    public String findAdvantages(Integer resumeId) {
        Resume resume = resumeMapper.selectByResumeId(resumeId);
        return resume.getAdvantages();
    }

    @Override
    public boolean findIsAdvantage(Integer resumeId) {
        Resume resume = resumeMapper.selectByResumeId(resumeId);
        if (resume!=null){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public void updateAdvantage(Integer id, String advantage) {
        resumeMapper.updateAdvantages(id,advantage);
    }

    @Override
    public void insertAdvantage(Integer id, String advantages) {
        resumeMapper.insertAdvantages(id,advantages);
    }

    @Override
    public void delAdvantage(Integer personId) {
        String advantage="";
        resumeMapper.updateAdvantages(personId,advantage);
    }
/*=============================================================================*/
    @Override
    public String findCredentials(Integer resumeId) {
        Resume resume = resumeMapper.selectByResumeId(resumeId);
        return resume.getCredentials();
    }

    @Override
    public boolean findIsCredentials(Integer id) {
        Resume resume = resumeMapper.selectByResumeId(id);
        if (resume!=null){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public void updateCredentials(Integer id, String credentials) {
        resumeMapper.updateCredentials(id,credentials);
    }

    @Override
    public void insertCredentials(Integer personId, String credentials) {
        resumeMapper.insertCredentials(personId,credentials);
    }

    @Override
    public void delCredentials(Integer personId) {
        String credentials="";
        resumeMapper.updateCredentials(personId,credentials);
    }

    @Override
    public List<Resume> findByPersonId(Integer personId) {
        return resumeMapper.selectAllByPersonId(personId);
    }

    @Override
    public Integer findNewId() {
        return resumeMapper.findNewId();
    }


}
